package com.wb.spring.boot.autoconfigure;

import com.wb.spring.boot.autoconfigure.annotation.ConditionalOnWbClientEnabled;
import com.wb.spring.boot.autoconfigure.client.WbClientSpecification;
import com.wb.spring.boot.autoconfigure.core.WbContext;
import com.wb.spring.boot.autoconfigure.http.*;
import com.wb.spring.boot.autoconfigure.register.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;


/**
 * @Author deeprado
 * @Date 2022/8/25 19:25
 */
@ConditionalOnWbClientEnabled
@Configuration
@ImportAutoConfiguration({WbRegisterAutoConfiguration.class, WbClientAutoConfiguration.class})
public class WbRpcAutoConfiguration {
    @Autowired(required = false)
    List<WbClientSpecification> configurations = new ArrayList<>();

    @Bean
    @ConditionalOnMissingBean
    public WbProperties wbProperties() {
        return new WbProperties();
    }

    @Bean
    public WbContext wbContext(){
        WbContext context = new WbContext();
        context.setConfigurations(configurations);
        return context;
    }
}
